﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PloobsEngine.SceneControl;
using PloobsEngine.IA;
using Etapa1.Pedestrian;
using Microsoft.Xna.Framework;
using Bnoerj.AI.Steering;

namespace Etapa1.ComercioEspacial
{
    public class Nave : IAgent
    {
        List<Planeta> list;
        public Nave(SteerObject representacao, List<Planeta> list)
        {
            this.list = list;
            this.representacao = representacao;
            representacao.Agente = this;
        }

        public void GoTo(String planetName)
        {
            (representacao.Vehicle as NaveVeiculo).IspathFollow = true;
            Planeta p = list.First((a) => a.NomeSistema == planetName);
            

            Vector3[] v = new Vector3[] { representacao.Position, p.Obj.Position };

            (representacao.Vehicle as NaveVeiculo).Path = new PolylinePathway(v.Count(),
                                              v,
                                              25,
                                              false);

            (representacao.Vehicle as NaveVeiculo).Radius = p.Obj.Modelo.GetBoudingSphere().Radius * p.Obj.PhysicObject.Scale.X;
         
   

        }

        public SteerObject representacao;
        public float velocidade;
        public Rotas rotaAtiva = null;
        public Planeta PlanetaNoLocal = null;
        public string Nome;

        public float estoque;
        public List<Produto> estoqueNow = new List<Produto>();

        public Agente dono;

        #region IAgent Members

        public void Update(Microsoft.Xna.Framework.GameTime gt)
        {

        }

        public IObject Obj
        {
            get
            {
                return representacao;
            }
            set
            {
                throw new Exception();
                //this.representacao = value;
            }
        }

        #endregion

    }
}
